package com.lzl.controller;

import com.lzl.pojo.Dept;
import com.lzl.service.DeptClientService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class DeptConsumerController {

    // 消费者不应该有service层
    // RestTemplate提供给用户直接调用即可, 提供的服务就是给用户多种远程便捷访问Http服务的方法
    @Resource
    private RestTemplate restTemplate;

   @Resource
   private DeptClientService clientService;

    @RequestMapping("/consumer/dept/list")
    public List<Dept> getList(){
        return clientService.selectAll();
    }

    @RequestMapping("/consumer/dept/get/{id}")
    public Dept get(@PathVariable("id") Long id){
        return clientService.selectById(id);
    }
}
